// 1 引入 创建stoer的方法
import { legacy_createStore as createStore } from "redux";
// 1 引入 reducer
import reducer from "./reducer";
// 1 引入 连接浏览器redux 调试工具 库
import { composeWithDevTools } from "redux-devtools-extension";
// 1 引入 useDispatch  useSelector  TypedUseSelectorHook
// import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";

// 2 创建store 要求传达 reduce-函数  用上 链接调试工具的 函数   composeWithDevTools
const store = createStore(reducer, composeWithDevTools());

// 3 导出 store
export default store;

// 针对 ts 特有的配置

// 从 store 本身推断出 `RootState` 和 `AppDispatch` 类型
export type RootState = ReturnType<typeof store.getState>;
// 推断出类型: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = typeof store.dispatch;
